home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / raypaint / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  3.2 KB  |  167 lines

  1. /*
  2.  * main.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * main.c,v 4.1 1994/08/09 08:06:23 explorer Exp
  17.  *
  18.  * main.c,v
  19.  * Revision 4.1  1994/08/09  08:06:23  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:27  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0  91/07/17  17:36:46  kolb
  26.  * Initial version.
  27.  * 
  28.  * 
  29.  */
  30.  
  31. char rcsid[] = "main.c,v 4.1 1994/08/09 08:06:23 explorer Exp";
  32.  
  33. #include "rayshade.h"
  34. #include "options.h"
  35. #include "stats.h"
  36. #include "viewing.h"
  37. #include "picture.h"
  38.  
  39. #ifdef AMIGA
  40. #ifndef __GNUC__
  41. long InitTime[2];
  42. #endif
  43. #endif
  44.  
  45. void RSInitialize(), RSStartFrame();
  46. int gray;
  47.  
  48. int
  49. main(argc, argv)
  50. int argc;
  51. char **argv;
  52. {
  53.     Float utime, stime;
  54.  
  55. #ifdef AMIGA
  56. #ifndef __GNUC__
  57.         timer(InitTime);
  58. #endif
  59.         ReducePriority();
  60. #endif
  61.  
  62.     /*
  63.       * Initialize variables, etc.
  64.      */
  65.     RSInitialize(argc, argv);
  66.     RSStartFrame(Options.startframe);
  67.     /*
  68.       * Print more information than we'll ever need to know...
  69.      */
  70.     if (Options.verbose) {
  71.         extern Geom *World;
  72.         /* World object info. */
  73.         AggregatePrintInfo(World, Stats.fstats);
  74.         /* Print info about rendering options and the like. */
  75.         RSOptionsList();
  76.     }
  77.     /*
  78.      * Print preprocessing time.
  79.      */
  80.     RSGetCpuTime(&utime, &stime);
  81.     fprintf(Stats.fstats,"Preprocessing time:\t");
  82.     fprintf(Stats.fstats,"%2.2fu  %2.2fs\n", utime, stime);
  83.     fprintf(Stats.fstats,"Starting trace.\n");
  84.     (void)fflush(Stats.fstats);
  85.     /*
  86.      * Render the image.
  87.      */
  88.     Render(argc, argv, gray);
  89.     StatsPrint();
  90.     return 0;
  91. }
  92.  
  93. static void
  94. RSStartFrame(frame)
  95. int frame;
  96. {
  97.     /*
  98.      * Set the frame start time
  99.      */
  100.     Options.framenum = frame;
  101.     Options.framestart = Options.starttime +
  102.             Options.framenum*Options.framelength;
  103.     SamplingSetTime(Options.framestart, Options.shutterspeed,
  104.             Options.framenum);
  105.     /*
  106.      * Set up viewing parameters.
  107.      */
  108.     RSViewing();
  109.     /*
  110.      * Initialize world
  111.      */
  112.     WorldSetup();
  113. }
  114.  
  115. /*
  116.  * Initialize non-time-varying goodies.
  117.  */
  118. static void
  119. RSInitialize(argc, argv)
  120. int argc;
  121. char **argv;
  122. {
  123.     int i;
  124.  
  125.     /*
  126.       * Initialize variables, etc.
  127.      */
  128.     RSSetup();
  129.     /*
  130.      * Steal the gray option, -M (mono, OK?)
  131.      */
  132.     gray = 0;
  133.     for (i = 1; i < argc; ++i) {
  134.         if ('-' != argv[i][0] || 'M' != argv[i][1]) {
  135.             continue;
  136.         }
  137.         gray = 1;
  138.         for (; i < argc; ++i) {
  139.             argv[i] = argv[i+1];
  140.         }
  141.         --argc;
  142.     }
  143.     /*
  144.      * Parse options from command line.
  145.      */
  146.     RSOptionsSet(argc, argv);
  147.     /*
  148.      * Process input file.
  149.      */
  150.     if (Options.verbose) {
  151.         VersionPrint();
  152.         fprintf(Stats.fstats,"Reading input file...\n");
  153.         (void)fflush(Stats.fstats);
  154.     }
  155.     RSReadInputFile();
  156.     /*
  157.      * Set variables that weren't set on command line
  158.      * or in input file.
  159.      */
  160.     RSCleanup();
  161.     /*
  162.      * Set sampling options.
  163.      */
  164.     SamplingSetOptions(Options.samples, Options.gaussian,
  165.                Options.filterwidth);
  166. }
  167.